package com.ceres.system.controller;

import com.ceres.entity.Result;
import com.ceres.entity.StatusCode;
import com.ceres.system.pojo.Menu;
import com.ceres.system.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @GetMapping("/findAll")
    public Result findAllMenu(String category){
        try {
            List<Menu> menuList = menuService.findAll(category);
            return new Result(true, StatusCode.OK,menuList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, StatusCode.ERROR);
        }
    }
}
